﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessModel;
using BusinessModel.EntityModel;
using DataBaseAccessLib;

namespace SDZJ.ManagerView.SystemManager
{
    public partial class EditUserInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //                <asp:BoundField HeaderText="是否禁用" DataField="DISABLED" SortExpression="DISABLED"/>

                userName.Text = Request.QueryString["sName"].ToString();
                //string arg = "sName=" + sName + "&sNice=" + sNice + "&userid=" + userid + "&sable=" + sable + "&slock" + slock;
                niceName.Text=Request.QueryString["sNice"].ToString();
                string enable = Request.QueryString["sable"].ToString();
                if ( enable== "是")
                    isEnable.Checked = true;
                string locked=Request.QueryString["slock"].ToString();
                if ( locked== "是")
                    isLock.Checked = true;
                usid.Value = Request.QueryString["userid"].ToString();
                
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            try
            {

                string userid = usid.Value;

                EntityOprHelper helper = new EntityOprHelper();

                studentClass userInf = new studentClass();
                if (isEnable.Checked)
                    userInf.disabled = 1;
                else
                    userInf.disabled = 0;
                if (isLock.Checked)
                    userInf.locked = 1;
                else
                    userInf.locked = 0;
                Security secPass = new Security();
                string enuserPass = secPass.Encrypt(password.Text);
                userInf.nicename = niceName.Text;
                userInf.username = userName.Text;
                userInf.password = enuserPass;
                userInf.userid = userid;


                if (userInf != null)
                {
                    bool b = helper.EditEntity<studentClass>(userInf);
                    if (b)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "closeDiv();alert('更新完毕');", true);
                       
                    }
                }


            }
            catch (Exception ex)
            {

            }

        }
    }
}